require 'tire'
Tire.index 'blog_posts' do
delete
create 
store :title => '1', :content => ['Post One']
store :title => '2', :content => ['Post two']
refresh
end
class BlogPost
  include Mongoid::Document
  field :title, type: String
  field :content, type: String
  include Tire::Model::Search
  include Tire::Model::Callbacks

  def self.search(search)
    if search 
      search_string= Regexp.new(Regexp.escape(search), "i")
      find(:all, :conditions => {'content' => search_string})
    else
      find(:all)
    end
  end
end
